home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / xmasspak / dosdir / dd2.asm < prev    next >
Encoding:
Assembly Source File  |  1994-11-26  |  8.3 KB  |  317 lines

  1. ;-----------------------------------------
  2. ; Universal Dos Routine (UDR)
  3. ;
  4. ; (c) 09.94 by Capella/Escape
  5. ;
  6. ; NOT FOR RELEASE !!!
  7. ;-----------------------------------------
  8. ; routine searching for max. 200 names
  9. ; needs 3531 Bytes of Data-segment
  10. ;-----------------------------------------
  11.  
  12. ideal
  13. model large
  14. p386n
  15. stack 256
  16.  
  17. assume cs:coding
  18.  
  19. segment coding
  20.  
  21. max_files  = 200
  22. max_paths  = 10                
  23.  
  24. anti_virus      db "ESCAPE"
  25.                 
  26. start:          mov ax,data1
  27.                 mov ds,ax
  28.                 assume ds:data1
  29.  
  30.                 mov ax,0003h
  31.                 int 10h
  32.                 
  33.                 mov eax,[cs:0000]        ;checks if program is changed
  34.                 cmp eax,"ACSE"
  35.                 je virusc1
  36. virusc2:        mov ah,09h
  37.                 mov dx,offset virus_mess
  38.                 int 21h
  39.                 jmp exit
  40. virusc1:        mov ax,[cs:0004]
  41.                 cmp ax,"PE"
  42.                 je virusc2
  43.                 
  44.                 mov dx,offset dir_puffer   ;set pointer to new DTA-puffer
  45.                 mov ax,1a00h
  46.                 int 21h
  47.                 
  48.                 call ask_drive
  49.                 
  50.                 xor dl,dl
  51.                 mov di,offset path_sign
  52.                 call ask_path
  53.                 
  54.                 mov dx,offset search_name
  55.                 call ask_subpaths
  56.                 
  57.                 mov dx,offset search_name
  58.                 call ask_files
  59.                 
  60.                 call display_dir
  61.  
  62.  
  63. warte:          in al,60h
  64.                 cmp al,01h
  65.                 jne warte
  66.  
  67. exit:           mov ax,4c01h
  68.                 int 21h
  69. ;-----------------------------------------
  70. ; ASK_DRIVE
  71. ;
  72. ; OUT:  AL : 0= Drive A
  73. ;            1= Drive B
  74. ;            2= Drive C
  75. ;            3= Drive D
  76. ;            4= Drive E
  77. ;-----------------------------------------
  78. ask_drive:      mov ax,1900h
  79.                 int 21h
  80.  
  81.                 cmp al,0
  82.                 jne ad1
  83.                 mov [ds:drive_no],"A"
  84.                 ret
  85. ad1:            cmp al,1
  86.                 jne ad2
  87.                 mov [ds:drive_no],"B"
  88.                 ret
  89. ad2:            cmp al,2
  90.                 jne ad3
  91.                 mov [ds:drive_no],"C"
  92.                 ret
  93. ad3:            cmp al,3
  94.                 jne ad4
  95.                 mov [ds:drive_no],"D"
  96.                 ret
  97. ad4:            cmp al,4
  98.                 jne ad5
  99.                 mov [ds:drive_no],"E"
  100.                 ret
  101. ad5:            mov [ds:drive_no],"?"
  102.                 ret
  103. ;-----------------------------------------
  104. ; ASK_PATH
  105. ;
  106. ; IN:   DS:DI = FAR-Pointer to Puffer
  107. ;       DL    = Drive : 0= current Drive
  108. ;                       1= Drive A
  109. ;                       2= Drive B
  110. ;                       3= Drive C
  111. ;                       4= Drive D
  112. ;                       5= Drive E
  113. ;
  114. ; OUT:  Carry-Flag= 1 then AX= Errorcode
  115. ;-----------------------------------------
  116. ask_path:       mov ax,4700h
  117.                 int 21h
  118.                 jnc ap1
  119.                 mov [ds:error_code],ax
  120. ap1:            ret
  121. ;-----------------------------------------
  122. ; ASK_FILES
  123. ;
  124. ; IN:  DS:DX = FAR-Pointer of Filename to search for
  125. ;      
  126. ; OUT: Carry-Flag=1 then AX= Errorcode
  127. ;-----------------------------------------
  128. ask_files:      xor cx,cx               ;attribute-code for normal files
  129.                 xor bp,bp               ;file-pointer to zero
  130.                 mov di,offset file_size
  131.                 mov si,offset dir_puffer
  132.                 xor ax,ax
  133.                 mov cx, max_files*13*4/2  ;clear file_size
  134. af3:            mov [ds:di],ax
  135.                 add di,02h
  136.                 loop af3
  137.                 mov di,offset file_size
  138.                 mov ax,4e00h
  139.                 int 21h
  140.                 jnc af1
  141.                 mov [ds:error_code],ax
  142. af2:            mov [ds:real_files],bp
  143.                 ret
  144. af1:            call get_para
  145.                 inc bp
  146.                 cmp bp,max_files
  147.                 jae af2
  148.                 mov ax,4f00h
  149.                 int 21h
  150.                 jnc af1
  151.                 mov [ds:error_code],ax
  152.                 mov [ds:real_files],bp
  153.                 ret
  154.                 
  155. get_para:       push si           ;get filename
  156.                 push di                          
  157.                 xor cx,cx
  158. af5:            mov al,[ds:si+30]
  159.                 cmp al,0
  160.                 je af4
  161.                 mov [ds:di],al
  162.                 inc si
  163.                 inc di
  164.                 inc cx
  165.                 cmp cx,13
  166.                 je af4
  167.                 jmp af5
  168. af4:            pop di            ;get filesize
  169.                 pop si
  170.                 add di,13
  171.                 mov eax,[ds:si+26]
  172.                 mov [ds:di],eax
  173.                 add di,4
  174.                 ret
  175. ;-----------------------------------------
  176. ; ASK_SUBPATHS
  177. ;
  178. ; OUT: AL=0 -no sub_paths found
  179. ;         1 -sub_paths found
  180. ;      CX= amount of sub_paths
  181. ;-----------------------------------------
  182. ask_subpaths:   mov cx,10h          ;attribute-code for sub_paths
  183.                 xor bp,bp
  184.                 mov si,offset dir_puffer
  185.                 mov di,offset sub_paths
  186.                 xor ax,ax
  187.                 push di
  188.                 push cx
  189.                 mov cx,max_paths*13
  190. asp3:           mov [ds:di],al
  191.                 inc di
  192.                 loop asp3
  193.                 pop cx
  194.                 pop di
  195.                 mov ax,4e00h
  196.                 int 21h
  197.                 jnc asp1
  198.                 mov [ds:error_code],ax
  199.                 mov [ds:real_paths],bp
  200.                 ret
  201. asp1:           call get_subpara
  202.                 cmp bp,max_paths
  203.                 jb asp2
  204.                 mov [ds:real_paths],bp
  205.                 ret
  206. asp2:           mov ax,4f00h
  207.                 int 21h
  208.                 jnc asp1
  209.                 mov [ds:error_code],ax
  210.                 mov [ds:real_paths],bp
  211.                 ret
  212.  
  213. get_subpara:    push si
  214.                 push di
  215.                 xor cx,cx
  216.                 cmp [byte ds:si+21],10h
  217.                 je gsp2
  218.                 pop di
  219.                 pop si
  220.                 ret
  221. gsp2:           mov al,[ds:si+30]
  222.                 cmp al,0
  223.                 je gsp1
  224.                 mov [ds:di],al
  225.                 inc si
  226.                 inc di
  227.                 jmp gsp2
  228. gsp1:           pop di
  229.                 pop si
  230.                 add di,13
  231.                 inc bp
  232.                 ret
  233. ;-----------------------------------------
  234. ; DISPLAY_DIR
  235. ;
  236. ; Simple display-routine to test out the
  237. ; functions of this module
  238. ;-----------------------------------------
  239. display_dir:    mov ax,0b800h
  240.                 mov es,ax
  241.                 assume es:0b800h
  242.                 xor bx,bx
  243.                 xor bp,bp
  244.                 xor di,di
  245.                 mov ah,04h
  246.                 mov si,offset file_size
  247.  
  248. dd2:            push si
  249.                 push di
  250.  
  251.                 mov cx,13
  252. dd1:            mov al,[ds:si]
  253.                 mov [es:di],ax
  254.                 inc si
  255.                 add di,02
  256.                 loop dd1
  257.  
  258.                 pop di
  259.                 pop si
  260.                 add si,13+4
  261.                 add di,160
  262.  
  263.                 inc bp
  264.                 cmp bp,[ds:real_files]
  265.                 je dd3
  266.                 
  267.                 inc bx
  268.                 cmp bx,80
  269.                 jne dd2
  270.  
  271. dd3:            mov si,offset sub_paths
  272.                 mov di,20*2
  273.                 xor bx,bx
  274.                 mov bp,[ds:real_paths]
  275.                 
  276. dd5:            push di
  277.                 mov cx,13
  278. dd4:            mov al,[ds:si]
  279.                 mov [es:di],al
  280.                 inc si
  281.                 add di,02h
  282.                 loop dd4
  283.                 pop di
  284.                 
  285.                 add di,160
  286.  
  287.                 inc bx
  288.                 cmp bx,bp
  289.                 jne dd5
  290.                 ret
  291.                 
  292.  
  293.  
  294. ends coding
  295.  
  296.  
  297. segment  data1
  298.  
  299. virus_mess  db 13,10,"- ATTENTION !!! ORIGINAL FILE IS CHANGED....MAYBE VIRUS !!!"
  300.             db 13,10,"  PLEASE CHECK YOUR SYSTEM !!!!!",13,10,"$"
  301.  
  302. dir_puffer  db 43 dup (0)
  303. error_code  dw 00
  304. search_name db "*.*",0
  305. real_files  dw 00
  306. real_paths  dw 00
  307. drive_no    db 0
  308. path_sign   db 80 dup (0)
  309. sub_paths   db max_paths*13 dup (0)
  310. file_size   db max_files*13 dup (0)
  311.             db max_files*4 dup (0)
  312.  
  313. ends  data1
  314.  
  315. end start
  316.  
  317.